using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Mgh.Data.Sql;
using Jewelry.BussinessLayer;
using Jewelry.Entities;
using System.Globalization;

public partial class Pages_AViewPayment : Mgh.UI.Sql.PageBase
{
    #region properties

    private string OrderID
    {
        get { return Request.QueryString["oid"] == null ? string.Empty : Request.QueryString["oid"]; }
    }

    #endregion

    #region events

    override protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!IsPostBack)
        {
            if (!string.IsNullOrEmpty(OrderID))
                this.bindData();
        }
    }

    protected void clickUpdate(object sender, EventArgs e)
    {
        PaymentBLL bn = new PaymentBLL(getCurrentConnect());
        if (!bn.updateStatus(Label1.Text, dlStatus.SelectedValue))
        {
            cval.IsValid = false;
            cval.Text = bn.getMessage();
        }
    }

    #endregion

    #region functions

    private void bindData()
    {
        PaymentBLL bn = new PaymentBLL(getCurrentConnect());
        DataSources.Jw_Vw_PaymentDataTable tb = bn.getPayment(this.OrderID);
        if (tb != null)
        {
            if (tb.Count > 0)
            {
                Label1.Text = tb[0].OrID;
                Label2.Text = tb[0].IsLoaiTheNull() ? string.Empty : tb[0].LoaiThe;
                Label3.Text = tb[0].IsMaSoTheNull() ? string.Empty : tb[0].MaSoThe;
                Label4.Text = tb[0].IsLoaiThanhToanNull() ? string.Empty : tb[0].LoaiThanhToan;
                Label5.Text = tb[0].IsBatDauNull() ? string.Empty : tb[0].BatDau.ToString("dd/MM/yyyy");
                Label6.Text = tb[0].IsKetThucNull() ? string.Empty : tb[0].KetThuc.ToString("dd/MM/yyyy");
                dlStatus.SelectedValue = tb[0].IsTrangThaiNull() ? string.Empty : tb[0].TrangThai;
                Label8.Text = tb[0].IsPhiVanChuyenNull() ? "$0" : tb[0].PhiVanChuyen.ToString("$#,#", CultureInfo.InvariantCulture);
                Label9.Text = tb[0].IsTienDonHangNull() ? "$0" : tb[0].TienDonHang.ToString("$#,#", CultureInfo.InvariantCulture);
            }
        }
        else
        {
            cval.IsValid = false;
            cval.Text = bn.getMessage();
        }

    }

    #endregion
}
